﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Adams.Web.Data.Security
{
    public static class Login
    {
        public static void ClearLockout(int MemberId)
        {
            DB.Run(@"
UPDATE Membership.Members SET 
FailedLoginAttempts = 0, LastLoginAttempt = GETUTCDATE()
WHERE MemberID = @MemberID
", CommandType.Text,
                DB.CreateParameter("@MemberID", MemberId, SqlDbType.Int));
        }

        public static void UpdateLockout(int MemberId)
        {
            DB.Run(@"
UPDATE Membership.Members SET 
FailedLoginAttempts = (FailedLoginAttempts + 1), LastLoginAttempt = GETUTCDATE()
WHERE MemberID = @MemberID
", CommandType.Text,
                    DB.CreateParameter("@MemberID", MemberId, SqlDbType.Int));
        }
    }
}
